home *** CD-ROM | disk | FTP | other *** search
- on tellNetscapeURL theURL
- global gMasterAppObject
- if not insureMasterApp() then
- warning("tellNetscapeURL(): insureMasterApp() failed")
- return 0
- end if
- set nsID to 0
- set nsIDs to netscapeWindowIDs()
- set theCount to count(nsIDs)
- if theCount > 1 then
- killAllNetscapeTasks()
- else
- if theCount = 1 then
- set nsID to getAt(nsIDs, 1)
- end if
- end if
- if nsID = 0 then
- set nsPath to gMasterAppObject(mLocateExecutable, "netscape.exe")
- if word 1 of nsPath = "Error:" then
- set nsPath to getExtensionApp("htm")
- if word 1 of nsPath = "Error:" then
- warning("tellNetscapeURL(): no application registered to handle .htm files")
- return "Error: no application registered to handle .htm files"
- end if
- set justFile to fileOnly(nsPath)
- if not (justFile contains "netscape") then
- warning("tellNetscape(): something other than Netscape handles .htm files")
- return "Error: something other than Netscape handles .htm files"
- end if
- end if
- set nsModuleID to gMasterAppObject(mLaunchButDontActivate, nsPath, EMPTY)
- if nsModuleID < 32 then
- warning("tellNetscape(): problem launching Netscape (" & nsModuleID & ")")
- return "Error: tellNetscape(): problem launching Netscape (" & nsModuleID & ")"
- end if
- set giveUpTicks to the ticks + (15 * 60)
- set Ok to 0
- repeat while 1
- set nsIDs to netscapeWindowIDs()
- set theCount to count(nsIDs)
- if theCount > 0 then
- set Ok to 1
- exit repeat
- end if
- gMasterAppObject(mFeedGenericTimeSlice)
- end repeat
- if not (Ok = 1) then
- warning("tellNetscape(): fifteen second timeout after launching Netscape")
- return "Error: tellNetscape(): fifteen second timeout after launching Netscape"
- end if
- set nsID to getAt(nsIDs, 1)
- set giveUpTicks to the ticks + (10 * 60)
- repeat while the ticks < giveUpTicks
- gMasterAppObject(mFeedGenericTimeSlice)
- end repeat
- end if
- set theTask to gMasterAppObject(mGetWindowTask, nsID)
- gMasterAppObject(mWindowToFront, nsID)
- gMasterAppObject(mFeedTimeSlice, theTask)
- gMasterAppObject(mFeedGenericTimeSlice)
- set giveUpTicks to the ticks + (0.5 * 60)
- repeat while the ticks < giveUpTicks
- gMasterAppObject(mFeedTimeSlice, theTask)
- gMasterAppObject(mFeedGenericTimeSlice)
- end repeat
- set theFront to gMasterAppObject(mGetTaskWindowIDs, theTask)
- if word 1 of theFront <> "Error:" then
- set nt to the number of words in theFront
- if nt >= 1 then
- repeat with i = 1 to nt
- set thisFrontText to word i of theFront
- set thisFrontID to integer(thisFrontText)
- if integerp(thisFrontID) then
- if gMasterAppObject(mWindowIsVisible, thisFrontID) then
- if gMasterAppObject(mWindowName, thisFrontID) <> EMPTY then
- if gMasterAppObject(mWindowParent, thisFrontID) = nsID then
- set kidsText to gMasterAppObject(mGetChildWindowIDs, thisFrontID)
- if word 1 of kidsText <> "Error:" then
- set nw to the number of words in kidsText
- if nw > 1 then
- repeat with j = 1 to nw
- set thisKidText to word j of kidsText
- set thisKid to integer(thisKidText)
- if integerp(thisKid) then
- if gMasterAppObject(mWindowName, thisKid) = "Cancel" then
- set theRect to gMasterAppObject(mGetWindowInsideRect, thisKid)
- set x to (integer(word 1 of theRect) + integer(word 3 of theRect)) / 2
- set y to (integer(word 2 of theRect) + integer(word 4 of theRect)) / 2
- gMasterAppObject(mFakeMouseClick, thisKid, x, y)
- gMasterAppObject(mFeedTimeSlice, theTask)
- gMasterAppObject(mFeedGenericTimeSlice)
- end if
- end if
- end repeat
- end if
- end if
- end if
- end if
- end if
- end if
- end repeat
- end if
- end if
- gMasterAppObject(mShowMenu, nsID)
- set giveUpTicks to the ticks + (0.25 * 60)
- repeat while the ticks < giveUpTicks
- gMasterAppObject(mFeedTimeSlice, theTask)
- gMasterAppObject(mFeedGenericTimeSlice)
- end repeat
- gMasterAppObject(mFakeCharacter, nsID, "f")
- set giveUpTicks to the ticks + (0.25 * 60)
- repeat while the ticks < giveUpTicks
- gMasterAppObject(mFeedTimeSlice, theTask)
- gMasterAppObject(mFeedGenericTimeSlice)
- end repeat
- gMasterAppObject(mFakeCharacter, nsID, "l")
- set giveUpTicks to the ticks + (0.25 * 60)
- repeat while the ticks < giveUpTicks
- gMasterAppObject(mFeedTimeSlice, theTask)
- gMasterAppObject(mFeedGenericTimeSlice)
- end repeat
- set taskWindowIDs to gMasterAppObject(mGetTaskWindowIDs, theTask)
- if word 1 of taskWindowIDs = "Error:" then
- warning("tellNetscapeURL(): error identifying Open Location dialog.")
- return "Error: tellNetscapeURL(): error identifying Open Location dialog"
- end if
- set ncw to the number of words in taskWindowIDs
- set olDialog to 0
- if ncw >= 1 then
- repeat with i = 1 to ncw
- set thisWindowText to word i of taskWindowIDs
- set thisWindow to integer(thisWindowText)
- if integerp(thisWindow) then
- if gMasterAppObject(mWindowName, thisWindow) = "Open Location" then
- set olDialog to thisWindow
- end if
- end if
- end repeat
- end if
- if olDialog = 0 then
- warning("tellNetscapeURL(): can't find Open Location dialog")
- return "Error: tellNetscapeURL(): can't find Open Location dialog"
- end if
- set olField to 0
- set okButton to 0
- set childWindowIDs to gMasterAppObject(mGetChildWindowIDs, olDialog)
- if word 1 of childWindowIDs = "Error:" then
- warning("tellNetscapeURL(): can't find children of Open Location dialog")
- return "Error: tellNetscapeURL(): can't find children of Open Location dialog"
- end if
- set ncw to the number of words in childWindowIDs
- if ncw >= 1 then
- repeat with i = 1 to ncw
- set thisIDText to word i of childWindowIDs
- set thisID to integer(thisIDText)
- if integerp(thisID) then
- if gMasterAppObject(mWindowType, thisID) = "Edit" then
- set olField to thisID
- end if
- if gMasterAppObject(mWindowName, thisID) = "Open" then
- set okButton to thisID
- end if
- end if
- end repeat
- end if
- if olField = 0 then
- warning("tellNetscapeURL(): can't find location field of Open Location dialog")
- return "Error: tellNetscapeURL(): can't find location field of Open Location dialog"
- end if
- if okButton = 0 then
- warning("tellNetscapeURL(): can't find OK button of Open Location dialog")
- return "Error: tellNetscapeURL(): can't find Open button of Open Location dialog"
- end if
- set nc to the number of chars in theURL
- if nc > 1 then
- repeat with i = 1 to nc
- gMasterAppObject(mFakeCharacter, olField, char i of theURL)
- set giveUpTicks to the ticks + 2
- repeat while the ticks < giveUpTicks
- gMasterAppObject(mFeedTimeSlice, theTask)
- gMasterAppObject(mFeedGenericTimeSlice)
- end repeat
- end repeat
- set theRect to gMasterAppObject(mGetWindowInsideRect, okButton)
- set x to (integer(word 1 of theRect) + integer(word 3 of theRect)) / 2
- set y to (integer(word 2 of theRect) + integer(word 4 of theRect)) / 2
- gMasterAppObject(mFakeMouseClick, okButton, x, y)
- set giveUpTicks to the ticks + 60
- repeat while the ticks < giveUpTicks
- gMasterAppObject(mFeedTimeSlice, theTask)
- gMasterAppObject(mFeedGenericTimeSlice)
- end repeat
- end if
- return 1
- end
-
- on netscapeWindowIDs
- global gMasterAppObject
- if not insureMasterApp() then
- warning("netscapeWindowIDs(): insureMasterApp() failed")
- return []
- end if
- set taskIDs to getNamedTasks("Netscape")
- set theCount to count(taskIDs)
- if theCount < 1 then
- warning("netscapeWindowIDs(): no Netscape tasks")
- return []
- end if
- set windowIDs to []
- repeat with i = 1 to theCount
- set thisTaskID to getAt(taskIDs, i)
- set thisWindowIDs to gMasterAppObject(mGetTaskWindowIDs, thisTaskID)
- if word 1 of thisWindowIDs <> "Error:" then
- set nw to the number of words in thisWindowIDs
- if nw >= 1 then
- repeat with j = 1 to nw
- set thisWindowText to word j of thisWindowIDs
- set thisWindowID to integer(thisWindowText)
- if integerp(thisWindowID) then
- if not gMasterAppObject(mWindowExists, thisWindowID) then
- next repeat
- end if
- if not gMasterAppObject(mWindowHasChildren, thisWindowID) then
- next repeat
- end if
- if gMasterAppObject(mWindowParent, thisWindowID) <> 0 then
- next repeat
- end if
- if not (gMasterAppObject(mWindowName, thisWindowID) contains "Netscape") then
- next repeat
- end if
- if not (gMasterAppObject(mWindowType, thisWindowID) contains "Afx:") then
- next repeat
- end if
- add(windowIDs, thisWindowID)
- end if
- end repeat
- end if
- end if
- end repeat
- if count(windowIDs) < 1 then
- warning("netscapeWindowIDs(): no Netscape windows")
- return []
- end if
- return windowIDs
- end
-
- on netscapeWindowID
- set windowIDs to netscapeWindowIDs()
- if count(windowIDs) > 1 then
- warning("netscapeWindowID(): ambiguous: more than one Netscape window")
- return 0
- end if
- if count(windowIDs) < 1 then
- warning("netscapeWindowID(): no Netscape window")
- return 0
- end if
- return getAt(windowIDs, 1)
- end
-
- on killAllNetscapeTasks
- global gMasterAppObject
- if not insureMasterApp() then
- warning("killAllNetscapeTasks(): insureMasterApp() failed")
- return 0
- end if
- set taskIDs to getNamedTasks("Netscape")
- set theCount to count(taskIDs)
- if theCount < 1 then
- return 1
- end if
- set windowIDs to []
- repeat with i = 1 to theCount
- set thisTaskID to getAt(taskIDs, i)
- set thisWindowIDs to gMasterAppObject(mGetTaskWindowIDs, thisTaskID)
- if word 1 of thisWindowIDs <> "Error:" then
- set nw to the number of words in thisWindowIDs
- if nw >= 1 then
- repeat with j = 1 to nw
- set thisWindowText to word j of thisWindowIDs
- set thisWindowID to integer(thisWindowText)
- if integerp(thisWindowID) then
- if not gMasterAppObject(mWindowExists, thisWindowID) then
- next repeat
- end if
- if not gMasterAppObject(mWindowHasChildren, thisWindowID) then
- next repeat
- end if
- if gMasterAppObject(mWindowParent, thisWindowID) <> 0 then
- next repeat
- end if
- if not (gMasterAppObject(mWindowName, thisWindowID) contains "Netscape") then
- next repeat
- end if
- if not (gMasterAppObject(mWindowType, thisWindowID) contains "Afx:") then
- next repeat
- end if
- add(windowIDs, thisWindowID)
- end if
- end repeat
- end if
- end if
- end repeat
- set theCount to count(windowIDs)
- if theCount >= 1 then
- set success to 1
- set killed to 1
- repeat with i = 1 to theCount
- set thisWindowID to getAt(windowIDs, i)
- set theTask to gMasterAppObject(mGetWindowTask, thisWindowID)
- if not (gMasterAppObject(mWindowExists, thisWindowID) = 1) then
- next repeat
- end if
- gMasterAppObject(mCloseWindow, thisWindowID)
- set giveUpTicks to the ticks + (10 * 60)
- set killed to 0
- repeat while the ticks < giveUpTicks
- if not (gMasterAppObject(mWindowExists, thisWindowID) = 1) then
- set killed to 1
- exit repeat
- end if
- gMasterAppObject(mFeedTimeSlice, theTask)
- gMasterAppObject(mFeedGenericTimeSlice)
- end repeat
- if not killed then
- warning("killAllNetscapeTasks(): ten second timeout while killing window " & i & " of " & theCount)
- set success to 0
- end if
- end repeat
- if success <> 1 then
- warning("killAllNetscapeTasks(): not all windows killed")
- return 0
- end if
- end if
- set giveUpTicks to the ticks + (10 * 60)
- repeat while the ticks < giveUpTicks
- set theTasks to getNamedTasks("Netscape")
- set theCount to count(theTasks)
- if theCount < 1 then
- return 1
- end if
- repeat with i = 1 to theCount
- set thisTask to getAt(theTasks, i)
- gMasterAppObject(mRudeQuitTask, thisTask, 0)
- gMasterAppObject(mFeedGenericTimeSlice)
- end repeat
- end repeat
- warning("killAllNetscapeTasks(): ten-second timeout, not all tasks killed")
- return 0
- end
-